<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        ref="crud"
        :table-loading="tableLoading"
        :page.sync="page"
        :data="tableData"
        :option="tableOption"
        @on-load="getList"
        @search-change="searchChange"
        @refresh-change="refreshChange"
      ></avue-crud>
    </basic-container>

  </div>
</template>

<script>
  import { queryStock } from '@/api/crm/stock_report';
  import { tableOption } from '@/const/crud/crm/stock_report';
  export default {
    name: 'basetable',
    data() {
      return {
        tableLoading: false,
        tableData: [],
        tableOption: tableOption,
        page: {
            total: 0, // 总页数
            currentPage: 1, // 当前页数
            pageSize: 20 // 每页显示多少条
        },
      }
    },
    methods:{
        refreshChange(info) {
            this.getList(this.page, this.filterForm(info.searchForm));
        },
        searchChange(form, done) {
            this.getList(this.page, form);
            done();
        },
      // 库存上报列表
      async getList(page, params) {
        let query = Object.assign({
          current: page.currentPage,
          size: page.pageSize,
        }, params);
        this.tableLoading = true;
        try {
          let res = await queryStock(query);
          this.tableLoading = false;
          this.tableData = res.data.data.records;
          this.page.total = res.data.data.total;
        }catch(err) {
          this.tableLoading = false;
        }  
      },
    }
  }

</script>
